package cn.schoolwow.util.test.module.query.instanceList.flow.group;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.test.module.common.domain.User;

import java.util.Arrays;
import java.util.List;

public class InitialUserRoleNameInstanceDataFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List<User> userList = (List<User>) flowContext.checkData("userList");

        List<String> roleNameList = Arrays.asList("超级管理员", "管理员");
        int mid = userList.size()/2;
        for(int i=0;i<mid;i++){
            User user = userList.get(i);
            user.roleName = roleNameList.get(0);
        }
        for(int i=mid;i<userList.size();i++){
            User user = userList.get(i);
            user.roleName = roleNameList.get(1);
        }
        flowContext.putTemporaryData("roleNameList", roleNameList);
    }

    @Override
    public String name() {
        return "初始化用户角色列表数据";
    }
}
